package com.example.service;


import com.example.entity.UserInfo;
import com.example.jdk_demo2.MQEventListener;
import com.example.jdk_demo2.MessageEventListener;

import java.util.Observable;

public abstract class LotteryServiceJdk extends Observable {


    public LotteryServiceJdk() {
        this.addObserver(new MessageEventListener());
        this.addObserver(new MQEventListener());
    }

    /**
     * 摇号的逻辑
     *
     * @param uid
     */
    public abstract UserInfo lottery(String uid);


    /**
     * 发送消息的逻辑
     *
     * @param uid
     */
    public UserInfo notify(String uid) {
        UserInfo lottery = lottery(uid);
        //发送通知
        setChanged();
        notifyObservers(lottery);
        return lottery;
    }

}
